<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{{ data.title }}</title>
    <style>
        /* 基础样式 - 专业商务风格 */
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: "Microsoft YaHei", "SimHei", Arial, sans-serif;
            font-size: 12px;
            line-height: 1.6;
            color: #333333;
            background-color: #ffffff;
            margin: 0;
            padding: 20px;
        }

        /* 页面布局 */
        .page {
            max-width: 210mm;
            margin: 0 auto;
            padding: 20mm;
            background: white;
            box-shadow: 0 0 10px rgba(0,0,0,0.1);
        }

        /* 标题样式 */
        .report-header {
            text-align: center;
            margin-bottom: 30px;
            padding-bottom: 20px;
            border-bottom: 2px solid #1f4e79;
        }

        .report-title {
            font-size: 24px;
            font-weight: bold;
            color: #1f4e79;
            margin-bottom: 10px;
        }

        .report-subtitle {
            font-size: 16px;
            color: #666666;
            margin-bottom: 5px;
        }

        .report-meta {
            font-size: 12px;
            color: #999999;
        }

        /* 章节样式 */
        .section {
            margin-bottom: 30px;
            page-break-inside: avoid;
        }

        .section-title {
            font-size: 16px;
            font-weight: bold;
            color: #1f4e79;
            background-color: #f8f9fa;
            padding: 12px 16px;
            border-left: 4px solid #1f4e79;
            margin-bottom: 16px;
        }

        .section-content {
            padding: 0 16px;
        }

        /* 表格样式 */
        .data-table {
            width: 100%;
            border-collapse: collapse;
            margin: 16px 0;
            font-size: 11px;
        }

        .data-table th {
            background-color: #1f4e79;
            color: white;
            padding: 12px 8px;
            text-align: center;
            font-weight: bold;
            border: 1px solid #1f4e79;
        }

        .data-table td {
            padding: 10px 8px;
            text-align: center;
            border: 1px solid #e0e0e0;
        }

        .data-table tr:nth-child(even) {
            background-color: #f8f9fa;
        }

        .data-table tr:hover {
            background-color: #e8f4ff;
        }

        /* 统计卡片 */
        .stats-cards {
            display: flex;
            justify-content: space-between;
            margin: 20px 0;
            gap: 16px;
        }

        .stat-card {
            flex: 1;
            background: #f8f9fa;
            border: 1px solid #e0e0e0;
            border-radius: 4px;
            padding: 16px;
            text-align: center;
        }

        .stat-value {
            font-size: 24px;
            font-weight: bold;
            color: #1f4e79;
            margin-bottom: 4px;
        }

        .stat-label {
            font-size: 12px;
            color: #666666;
        }

        /* 警示样式 */
        .warning {
            background-color: #fff3cd;
            border: 1px solid #ffeaa7;
            color: #856404;
            padding: 12px;
            border-radius: 4px;
            margin: 12px 0;
        }

        .error {
            background-color: #f8d7da;
            border: 1px solid #f5c6cb;
            color: #721c24;
            padding: 12px;
            border-radius: 4px;
            margin: 12px 0;
        }

        .success {
            background-color: #d4edda;
            border: 1px solid #c3e6cb;
            color: #155724;
            padding: 12px;
            border-radius: 4px;
            margin: 12px 0;
        }

        /* 高亮数据 */
        .highlight-number {
            color: #1f4e79;
            font-weight: bold;
        }

        .highlight-good {
            color: #28a745;
            font-weight: bold;
        }

        .highlight-bad {
            color: #dc3545;
            font-weight: bold;
        }

        /* 列表样式 */
        .report-list {
            margin: 16px 0;
            padding-left: 20px;
        }

        .report-list li {
            margin-bottom: 8px;
            line-height: 1.5;
        }

        /* 分页 */
        .page-break {
            page-break-before: always;
        }

        /* 页脚 */
        .report-footer {
            margin-top: 40px;
            padding-top: 20px;
            border-top: 1px solid #e0e0e0;
            text-align: center;
            color: #999999;
            font-size: 11px;
        }

        /* 打印样式 */
        @media print {
            .page {
                box-shadow: none;
                margin: 0;
                padding: 0;
            }
            
            body {
                background: white;
                font-size: 11px;
            }
            
            .section {
                page-break-inside: avoid;
            }
        }

        /* 无数据样式 */
        .no-data {
            text-align: center;
            color: #999999;
            font-style: italic;
            padding: 20px;
        }
    </style>
</head>
<body>
    <div class="page">
        <!-- 报告头部 -->
        <div class="report-header">
            <h1 class="report-title">{{ data.title }}</h1>
            <div class="report-subtitle">{{ data.subtitle }}</div>
            <div class="report-meta">
                报告类型: {{ data.report_focus }} | 生成时间: {{ data.generation_time }}
            </div>
        </div>

        <!-- 概览统计 -->
        <div class="section">
            <div class="section-title">📊 概览统计</div>
            <div class="section-content">
                <div class="stats-cards">
                    <div class="stat-card">
                        <div class="stat-value">{{ data.basic_stats.total_devices | format_number }}</div>
                        <div class="stat-label">设备总数</div>
                    </div>
                    <div class="stat-card">
                        <div class="stat-value">{{ data.basic_stats.total_regions | format_number }}</div>
                        <div class="stat-label">大区数量</div>
                    </div>
                    <div class="stat-card">
                        <div class="stat-value">{{ data.basic_stats.total_projects | format_number }}</div>
                        <div class="stat-label">项目数量</div>
                    </div>
                    <div class="stat-card">
                        <div class="stat-value">{{ data.basic_stats.period_days | format_number }}</div>
                        <div class="stat-label">统计天数</div>
                    </div>
                </div>
            </div>
        </div>

        <!-- 出勤率分析 -->
        <div class="section">
            <div class="section-title">📈 出勤率分析</div>
            <div class="section-content">
                <div class="stats-cards">
                    <div class="stat-card">
                        <div class="stat-value {{ 'highlight-good' if data.attendance_stats.overall_rate > 0.8 else 'highlight-bad' }}">
                            {{ data.attendance_stats.overall_rate | format_percentage }}
                        </div>
                        <div class="stat-label">整体出勤率</div>
                    </div>
                    <div class="stat-card">
                        <div class="stat-value">{{ data.attendance_stats.expected_days | format_number }}</div>
                        <div class="stat-label">应出勤天数</div>
                    </div>
                    <div class="stat-card">
                        <div class="stat-value">{{ data.attendance_stats.actual_days | format_number }}</div>
                        <div class="stat-label">实际出勤天数</div>
                    </div>
                    <div class="stat-card">
                        <div class="stat-value">{{ data.anomaly_devices.idle_count | format_number }}</div>
                        <div class="stat-label">完全缺勤设备</div>
                    </div>
                </div>

                {% if data.attendance_stats.region_data %}
                <table class="data-table">
                    <thead>
                        <tr>
                            <th>大区名称</th>
                            <th>工作天数</th>
                            <th>应出勤天数</th>
                            <th>出勤率</th>
                        </tr>
                    </thead>
                    <tbody>
                        {% for region in data.attendance_stats.region_data %}
                        <tr>
                            <td>{{ region.region_name }}</td>
                            <td>{{ region.工作天数 | format_number }}</td>
                            <td>{{ region.所有天数 | format_number }}</td>
                            <td class="{{ 'highlight-good' if region.大区出勤率 > 0.8 else 'highlight-bad' }}">
                                {{ (region.大区出勤率 * 100) | round(1) }}%
                            </td>
                        </tr>
                        {% endfor %}
                    </tbody>
                </table>
                {% endif %}
            </div>
        </div>

        <!-- 子模板内容 -->
        {% block content %}{% endblock %}

        <!-- 页脚 -->
        <div class="report-footer">
            <p>本报告由智能设备管理系统自动生成 | 数据准确性已验证 | 生成时间: {{ data.generation_time }}</p>
        </div>
    </div>
</body>
</html>